<template>
<div class="order_page">
    <head-top head-title="添加留言" go-back='true'></head-top>
    <div class="shoplist_container">
        <span>留言内容</span>
        <el-input type="textarea" :autosize="{ minRows: 10, maxRows: 16}" placeholder="请输入留言内容" v-model="leaveMessage">
        </el-input>

        <el-button type="success" round v-on:click='permiss'>提交</el-button>
        <el-button type="info" round v-on:click='back'>取消</el-button>
    </div>

</div>
</template>

<script>
import headTop from 'src/components/header/head'
export default {
    data() {
        return {
            goodsId: '',
            leaveMessage: '',
            createPerson: '',
            status: '1',
            userId: sessionStorage.getItem("userId"),
            userName: '',
        }
    },
    created() {
        this.goodsId = this.$route.query.id;
    },
    components: {
        headTop

    },

    methods: {
        permiss: function () {
            this.axios.get('http://172.16.9.7:8081/goods/message/addMessageByMessage', {
                    params: {
                        goodsId: this.goodsId,
                        userId: this.userId,
                        leaveMessage: this.leaveMessage,
                        createPerson: this.createPerson,
                        status: this.status
                    }
                })
                .then(res => {
                    console.log(res);
                    this.$router.go(-1);
                })
        },
        getName: function () {
            this.axios.get('http://172.16.9.7:8081/getUserById', {
                    params: {
                        userId: this.userId
                    }
                })
                .then(res => {
                    console.log(res);
                    this.userName = res.data;
                    this.createPerson = this.userName;
                })
        },
        back: function () {
            this.$router.go(-1);
        },

    },

    mounted() {
        this.getName();
    },
}
</script>

<style scoped>
.shoplist_container {
    margin-top: 41px;
    width: 328px;
    background-color: #fff;
    margin-bottom: 2rem;
}
</style>
